package com.qianfeng.exam.controller;


import com.qianfeng.exam.dto.R;
import com.qianfeng.exam.pojo.Authors;
import com.qianfeng.exam.service.IAuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/author")
public class AuthorController {
    @Autowired
    private IAuthorService authorService;
    @PostMapping("/authors")
    public R registerAuthor(@RequestBody Authors authors){
        System.out.println(authors);//有个问题! 自动生成的类 属性名全小写,和笔记中的json映射不上,当前只改了现在需要用的
        authorService.addAuthor(authors);
        return R.setOk(authors,"添加作者成功");//在mapper接口加option注解后 获取到了前端需要展示的 主键
    }

}
